package org.academic.texteditor.gui.plugin.text;

import org.academic.texteditor.gui.component.PageContainer;
import org.academic.texteditor.gui.component.PersonalizedTextPane;
import org.academic.texteditor.gui.feature.Page;
import org.academic.texteditor.gui.helper.DocumentManager;
import org.academic.texteditor.gui.plugin.BasePlugin;

public class PasteTextPlugin extends BasePlugin {

	private static final long serialVersionUID = 8128584655643633019L;
	
	private final String text;

	public PasteTextPlugin(String text) {
		super("pasteText");
		this.text = text;
	}

	@Override
	public void initialize(PageContainer pageContainer) {

	}
	
	@Override
	public void activate() {

	}

	@Override
	public void execute() {
		DocumentManager manager = DocumentManager.getInstance();
		PageContainer pageContainer = manager.getDocument();
		
		Page page = pageContainer.getActualPage();
		PersonalizedTextPane textPane = page.getText().getTextPane();
		int caretPosition = textPane.getCaretPosition();
		
		textPane.insert(caretPosition, text);
		textPane.requestFocus();
	}

	@Override
	public void deactivate() {

	}

	@Override
	public void destroy() {

	}


}
